const navBarHeight = wx.getWindowInfo().statusBarHeight + 44

Component({

  properties: {
    back: {
      type: Boolean,
      value: false
    },
    home: {
      type: Boolean,
      value: false
    },
    title: {
      type: String,
      value: 'Wechat'
    },
    titleColor: {
      type: String,
      value: '#ffffff'
    },
    background: {
      type: String,
      value: '#2f2f2f'
    }
  },

  data: {
    navBarHeight
  },

  methods: {
    home() {
      this.triggerEvent('home')
      // wx.reLaunch({
      wx.switchTab({
        url: '../index/index'
      })
    },

    back_new() {
      // 有了这一句，才能调用页面上的back方法。
      this.triggerEvent('back')
      
      console.log("getCurrentPages()[0]")
      var cPage = getCurrentPages()[0];//打印cPage 获取其中的data属性
      console.log(cPage)

    },
    back() {
      this.triggerEvent('back')

      let currentPages = getCurrentPages()
      
      if(currentPages[0].route == "pages/scene/scene") {
        console.log(currentPages[0].route)
        return
      }

      if (currentPages.length === 1) {

        // 由于我的页面是tab，所以要修改。
        // wx.redirectTo({
        //   url: '/index/index'
        // })

        wx.switchTab({
          url: '../index/index'
        })


      } else {
        wx.navigateBack()
      }
    }
  }
})
